//
// Description: 5785. 合并若干三元组以形成目标三元组
// Created by Loading on 2021/6/13.
//

#include <bits/stdc++.h>

using namespace std;

bool mergeTriplets(vector<vector<int>> &triplets, vector<int> &target) {
    //保留最大值结果的数组
    vector<int> res(3);
    for (auto &triplet : triplets) {
        //只有三元组中的三个元素都小于等于目标元组的三元素，更新最大值结果数组
        if (triplet[0] <= target[0] && triplet[1] <= target[1] && triplet[2] <= target[2]) {
            res = {max(res[0], triplet[0]), max(res[1], triplet[1]), max(res[2], triplet[2])};
        }
    }

    return res == target;
}

int main() {
    vector<vector<int>> triplets = {{2, 5, 3},
                                    {1, 8, 4},
                                    {1, 7, 5}};
    vector<int> target = {2, 7, 5};
    cout << mergeTriplets(triplets, target) << endl;
}